<?php
/**
 * @package		Joomla.Site
 * @subpackage	mod_sidebar
 * @copyright	Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die;

/**
 * @package		Joomla.Site
 * @subpackage	mod_sidebar
 * @since		1.5
 */
class modSideBarHelper
{
	public static function getCategories($rootID) {
		$dbo = JFactory::getDbo();
		$queryStr = "SELECT cat.id, cat.title"
				.	" FROM #__categories as cat"
				.	" WHERE cat.parent_id = '".$rootID."' and published='1' ORDER BY lft";
		$dbo->setQuery($queryStr);
		$rows = $dbo->loadObjectList();
		return $rows;
	}
	
	public static function getArticlesByCatID($catID){
		$dbo = JFactory::getDbo();
		$queryStr = "SELECT cont.id, cont.catid, cont.introtext, cont.title, cont.production, "
				.	"cont.directed_by, cont.coproduction, cont.alias, cont.film_version, cont.length, cont.trailer, cont.poster"
				.	" FROM #__content as cont"
				.	" WHERE cont.catid = '".$catID."' AND state='1' ORDER BY cont.ordering";
		$dbo->setQuery($queryStr);
		$rows = $dbo->loadObjectList();
		return $rows;
	}
}
